/**
 * \file Image.h
 * \brief Image declaration class
 * \author Edouard ROGE
 * \date 16 October 2012
 */

#ifndef _IMAGE_
#define _IMAGE_

#include "Core/Memory/HeapObject.h"
#include "Core/String/String.h"
#include "Core/File/URI.h"
#include "Core/Error/Error.h"
#include "Core/Array/Array.h"
#include "Math/Color/Color.h"

/**
 * \class Image
 * \brief Class to manipulate image, load/save, write/read ...
 */
class Image : public HeapObject
{
public:
	/**
	 * \fn Image();
	 * \brief Default constructor
	 */
	Image();

	/**
	 * \fn Image(uint32 _iWidth, uint32 _iHeight);
	 * \param _iWidth image's width
	 * \param _iHeight image's height
	 * \brief Constructor
	 */
	Image(uint32 _iWidth, uint32 _iHeight);

	/**
	 * \fn Image(const String & _path);
	 * \param _path file path of the image to load
	 * \brief Build an image from a file
	 */
	Image(const String & _path);

	/**
	 * \fn Image(const URI & _uri);
	 * \param _uri file path of the image to load
	 * \brief Build an image from a file
	 */
	Image(const URI & _uri);

	/**
	 * \fn Image(const Image & _image);
	 * \param _image image to copy
	 * \brief Copy constructor
	 */
	Image(const Image & _image);

	/**
	 * \fn virtual ~Image();
	 * \brief Destructor
	 */
	virtual ~Image();

	/**
	 * \fn uint32 GetWidth() const;
	 * \return image's width
	 * \brief Get the image's width
	 */
	uint32 GetWidth() const;

	/**
	 * \fn uint32 GetHeight() const;
	 * \return image's height
	 * \brief Get the image's height
	 */
	uint32 GetHeight() const;

	/**
	 * \fn const Color & operator()(uint32 i, uint32 j)const;
	 * \param i column index of the pixel
	 * \param j row index of the pixel
	 * \brief Get the color of a pixel identified by i and j
	 */
	const Color & operator()(uint32 i, uint32 j)const;

	/**
	 * \fn Color & operator()(uint32 i, uint32 j);
	 * \param i column index of the pixel
	 * \param j row index of the pixel
	 * \brief Get the color of a pixel identified by i and j
	 */
	Color & operator()(uint32 i, uint32 j);

	/**
	 * \fn error SaveToPNG(const URI & _uri)const;
	 * \param _uri file path to save
	 * \brief Save image to PNG
	 */
	error SaveToPNG(const URI & _uri)const;

	/**
	 * \fn error LoadFromFile(const URI & _uri);
	 * \param _uri file path to load
	 * \brief Load image from a file
	 */
	error LoadFromFile(const URI & _uri);

private:

	/** Image's width */
	uint32 m_iWidth;

	/** Image's Height*/
	uint32 m_iHeight;

	/** Array of color */
	Array<Color> m_Pixels;

};



#endif // _IMAGE_
